<template>
  <div class="dam-header">
    <header>
      <div class="header-left">
        <div class="dam-logo">
          <img class="img" alt src="@/assets/images/logo-gap-white.png" />
        </div>
        <div class="header-nav">
          <div
            @click="tapHeaderNav(index)"
            :class="['nav-item', index == indexNav ? 'active' : '']"
            v-for="(item, index) in headerNav"
            :key="index"
          >
            {{ item.name }}
          </div>
        </div>
      </div>
      <div class="header-right">
        <!-- <language
          :lang="local"
          @on-lang-change="setLocal"
          style="margin-right: 10px"
          v-if="$config.useI18n"
        /> -->
        <User :message-unread-count="unreadCount" />
      </div>
    </header>
  </div>
</template>
<script>
import User from "../../components/main/components/user";
import Language from "../main/components//language";
import { mapMutations, mapActions, mapGetters } from "vuex";

export default {
  name: "damHeader",
  components: {
    User,
    Language,
  },
  props:{
      headerNavIndex: null,
  },
  data() {
    return {
      headerNav: [
        {
          name: "Assets",
          id: "Assets",
        },
        {
          name: "Contact",
          id: "Assets",
        },
      ],
      indexNav: null
    };
  },
  created() {
    this.indexNav = this.headerNavIndex
  },
  computed: {
    unreadCount() {
      return this.$store.state.user.unreadCount;
    },
    local() {
      return this.$store.state.app.local;
    },
  },
  methods: {
    ...mapMutations(["setLocal"]),
    //   导航切换
    tapHeaderNav(index) {
        this.indexNav = index;
        if(index == 0) {
            this.$router.push({
                name: 'damHome'
            })
        }else {
            this.$router.push({
                name: 'damContact'
            })
        }
    },
  },
};
</script>
<style lang="less" scoped>
.dam-header {
    height: 52px;
  header {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: @primary-color;
    padding-right: 30px;
    position: fixed;
    width: 100vw;
    left: 0;
    top: 0;
    z-index: 9;
    .header-left {
      flex: 1;
      display: flex;
      .dam-logo {
        width: 260px;
        text-align: center;
        .img {
          width: 40px;
          vertical-align: middle;
        }
      }
      .header-nav {
        display: flex;
        align-items: center;
        .nav-item {
          margin-right: 60px;
          color: #fff;
          cursor: pointer;
          font-size: 16px;
          &:hover {
            opacity: 0.5;
          }
          &.active {
            font-weight: bold;
          }
        }
      }
    }
    .header-right {
      // width: 200px;
      display: flex;
    }
  }
}
</style>